<?php

namespace App\Console\Commands;

use App\Http\Model\LuckDraw;
use App\Http\Services\LuckDrawServices;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Redis;

class CommandCostUniverseValue extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'CommandCostUniverseValue';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '每日凌晨扣减星辰值';

    protected $activityService;
    protected $luckDrawModel;

    protected $log = 'ChangeUniversePool';
    protected $allUniverseValue = 'UNIVERSE:VALUE';//全服星辰值

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
        $this->activityService = new LuckDrawServices();
        $this->luckDrawModel = new LuckDraw();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $config = $this->luckDrawModel->getWishPoolConfig();
        //扣减星辰值
        $nowValue = Redis::get($this->allUniverseValue);
        $costValue = $nowValue - $config['costPoolNum'];
        if($costValue < 0){
           $costValue = 0;
        }
        Redis::set($this->allUniverseValue, $costValue);
    }
}